import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show debugPaintSizeEnabled;

void main() {
  debugPaintSizeEnabled = true;
  runApp(MyApp());
}



class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: "我是石头",
      theme: ThemeData(
        primarySwatch: Colors.red
      ),
      home: HomeScreen(),
    );
  }

}

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(

      body: FirstScreen(),
    );
  }
}
class FirstScreen extends StatelessWidget {


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.blue,
      appBar: AppBar(
        title: Text("Stone"),
      ),
      body: Stack(
        // 设置开始覆盖的位置
        alignment: Alignment.center,
        children: <Widget>[
          FlatButton(

            child: Text("小菜鸟"),
            onPressed: () {
              print("Stone");
            },
          ),

          //将覆盖上一个控件
        ],
    ),
    );
  }

  Future<void> _neverSatisfied(String title, {context: BuildContext}) async {
    return showDialog<void>(
      context: context,
      barrierDismissible: false, // user must tap button!
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text(title),
          content: SingleChildScrollView(
            child: ListBody(
              children: <Widget>[
                Text('我是石头'),
                Text('我是石头'),
              ],
            ),
          ),
          actions: <Widget>[
            FlatButton(
              child: Text('确定'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
            FlatButton(
              child: Text("取消",
              style: TextStyle(color: Colors.green),),
              onPressed: () {
                Navigator.of(context).pop();
              }
            ),
          ],
        );
      },
    );
  }

  _navigateAndDisplaySelection(BuildContext context) async {
    // Navigator.push returns a Future that will complete after we call
    // Navigator.pop on the Selection Screen!
    /*final result = Navigator.of(context).push(MaterialPageRoute(builder: (context) =>
        SecondScreen(title: "你好")));*/

    final result = await Navigator.push(
      context,
      new MaterialPageRoute(builder: (context) => new SecondScreen(title: "shitou",)),
    );

    Scaffold
        .of(context)
        .showSnackBar(new SnackBar(content: new Text("$result")));

  }
}

class SecondScreen extends StatelessWidget {

  String title;
  SecondScreen({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(

      appBar: AppBar(
        title: Text(title ?? "石头"),
      ),
      body: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[

          Align(
            alignment: Alignment.topLeft,
            heightFactor: 4.0,
            widthFactor: 1.0,
            child: Image.asset("images/home_checked.png"),
          ),

          Align(
            heightFactor: 4.0,
            widthFactor: 1.0,
            alignment: Alignment.topLeft,
            child: Image.asset("images/home_checked.png"),
          ),
        ],
      ),

    );
  }
}
